//
//  HomeTableViewCell.m
//  BaseFrameworkOC
//
//  Created by Vicent on 2021/9/6.
//

#import "HomeTableViewCell.h"
#import "UIView+Layout.h"
#import "NSString+Helper.h"

@interface HomeTableViewCell()

@property (weak, nonatomic) IBOutlet UILabel *titleLb;
@property (weak, nonatomic) IBOutlet UILabel *contentLb;

@end

static const CGFloat cPadding = 20.0;

@implementation HomeTableViewCell

@synthesize vm = _vm;


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (void)setVm:(HomeItemViewModel *)vm {
    _vm = vm;
    self.titleLb.text = vm.titleLbString;
    self.contentLb.text = vm.contentLbString;
}


- (HomeItemViewModel *)vm {
    if (_vm == nil) {
        _vm = [[HomeItemViewModel alloc] init];
    }
    return _vm;
}

- (CGFloat)rowHeightWithModel:(HomeItemViewModel *)vm {
    self.vm = vm;
    [self.contentView layoutIfNeeded];
    CGFloat height = self.contentLb.bottom + cPadding;
    if ([NSString isBlankString:self.vm.contentLbString]) {
        height = self.titleLb.bottom + cPadding;
    }
    return height;
}

@end
